/*
Copyright (c) 2009, Chris Gerlinsky
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY CHRIS GERLINSKY ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CHRIS GERLINSKY BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

//--------------------------------------------------------------------
#ifndef _dkbasic_h
#define _dkbasic_h
//--------------------------------------------------------------------
#include <avr/pgmspace.h>
#include "dkconstants.h"


//--------------------------------------------------------------------
// values for dkstatus (dkprogram.c)
#define DKSTATUS_OK			0
// 'next' part of 'for' loop
#define DKSTATUS_SKIPTONEXT	1
#define DKSTATUS_SKIPTOWEND 2

// DKSTATUS_BREAKLINE indicates the lowest dkstatus value that should cause interpretation of a line to stop
#define DKSTATUS_BREAKLINE	8

#define DKSTATUS_GOTO		8
#define DKSTATUS_RETURN		9
#define DKSTATUS_END		10
#define DKSTATUS_EDIT		11

#define DKSTATUS_FIRSTERROR			16
/*
#define DKSTATUS_SYNTAXERROR		16
#define DKSTATUS_MISSINGOPERAND		17
#define DKSTATUS_OPERANDMISMATCH	18
#define DKSTATUS_TYPEMISMATCH		19
#define DKSTATUS_ILLEGALFUNC		20
#define DKSTATUS_OUTOFMEM			21
#define DKSTATUS_UNDEFLINE			22
#define DKSTATUS_IFWITHOUTTHEN		23
#define DKSTATUS_BREAK				24
#define DKSTATUS_NEXTWITHOUTFOR		25
#define DKSTATUS_FORWITHOUTNEXT		26
#define DKSTATUS_WENDWITHOUTWHILE	27
#define DKSTATUS_RETURNWITHOUTGOSUB 28
#define DKSTATUS_DEVICEUNAVAILABLE	29
#define DKSTATUS_BADFILENUMBER		30
#define DKSTATUS_DEVICEIOERROR		31
#define DKSTATUS_SUBSCRIPTOUTOFRANGE 32
#define DKSTATUS_FILENOTFOUND		33
*/

// error codes as defined by GW-BASIC (offset by DKSTATUS_FIRSTERROR)
#define DKSTATUS_NEXTWITHOUTFOR		         (1  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_SYNTAXERROR                 (2  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_RETURNWITHOUTGOSUB          (3  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_OUTOFDATA                   (4  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_ILLEGALFUNCTIONCALL         (5  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_OVERFLOW                    (6  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_OUTOFMEMORY                 (7  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_UNDEFINEDLINENUMBER         (8  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_SUBSCRIPTOUTOFRANGE         (9  + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DUPLICATEDEFINITION         (10 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DIVISIONBYZERO              (11 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_ILLEGALDIRECT               (12 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_TYPEMISMATCH                (13 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_OUTOFSTRINGSPACE            (14 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_STRINGTOOLONG               (15 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_STRINGFORMULATOOCOMPLEX     (16 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_CANTCONTINUE                (17 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_UNDEFINEDUSERFUNCTION       (18 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_NORESUME                    (19 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_RESUMEWITHOUTERROR          (20 + DKSTATUS_FIRSTERROR)
//		DKSTATUS_UNPRINTABLEERROR 	21
#define DKSTATUS_MISSINGOPERAND              (22 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_LINEBUFFEROVERFLOW          (23 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DEVICETIMEOUT               (24 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DEVICEFAULT                 (25 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_FORWITHOUTNEXT              (26 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_OUTOFPAPER                  (27 + DKSTATUS_FIRSTERROR)
//		DKSTATUS_UNPRINTABLEERROR	28
#define DKSTATUS_WHILEWITHOUTWEND            (29 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_WENDWITHOUTWHILE            (30 + DKSTATUS_FIRSTERROR)
// 		DKSTATUS_UNPRINTABLEERROR   31-49
#define DKSTATUS_FIELDOVERFLOW               (50 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_INTERNALERROR               (51 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_BADFILENUMBER               (52 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_FILENOTFOUND                (53 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_BADFILEMODE                 (54 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_FILEALREADYOPEN             (55 + DKSTATUS_FIRSTERROR)
//      DKSTATUS_UNPRINTABLEERROR   56
#define DKSTATUS_DEVICEIOERROR               (57 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_FILEALREADYEXISTS           (58 + DKSTATUS_FIRSTERROR)
//		DKSTATUS_UNPRINTABLEERROR 	59-60
#define DKSTATUS_DISKFULL                    (61 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_INPUTPASTEND                (62 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_BADRECORDNUMBER             (63 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_BADFILENAME                 (64 + DKSTATUS_FIRSTERROR)
//      DKSTATUS_UNPRINTABLEERROR   65
#define DKSTATUS_DIRECTSTATEMENTINFILE       (66 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_TOOMANYFILES                (67 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DEVICEUNAVAILABLE           (68 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_COMMUNICATIONBUFFEROVERFLOW (69 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_PERMISSIONDENIED            (70 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DISKNOTREADY                (71 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_DISKMEDIAERROR              (72 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_ADVANCEDFEATURE             (73 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_RENAMEACROSSDISKS           (74 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_PATHFILEACCESSERROR         (75 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_PATHNOTFOUND                (76 + DKSTATUS_FIRSTERROR)

//start of dk-basic-specific error codes
#define DKSTATUS_IFWITHOUTTHEN				 (80 + DKSTATUS_FIRSTERROR)
#define DKSTATUS_BREAK						 (81 + DKSTATUS_FIRSTERROR)

//--------------------------------------------------------------------
#define DKNAME_STRING		(1<<0)		// DKNAME_ and DKVAR_ defines must match (should be changed to have only one)
#define DKNAME_INTEGER		(1<<1)
#define DKNAME_FLOATSINGLE	(1<<2)
#define DKNAME_FLOATDOUBLE	(1<<3)
#define DKNAME_PAREN		(1<<4)
#define DKNAME_BYTE			(1<<5)		// DK-BASIC feature (for more efficient arrays of bytes)

//--------------------------------------------------------------------

#define DKVAR_STRING		(1<<0)
#define DKVAR_INTEGER		(1<<1)
#define DKVAR_FLOATSINGLE	(1<<2)
#define DKVAR_FLOATDOUBLE	(1<<3)
#define DKVAR_ARRAY			(1<<4)
#define DKVAR_BYTE			(1<<5)		// DK-BASIC feature (for more efficient arrays of bytes)
#define DKVAR_DEFAULT		DKVAR_FLOATSINGLE


#define DK_MAX_ARRAY_DIMS	8				// maximum # of dimensions of an array (arbitrary maximum)
//--------------------------------------------------------------------
//--------------------------------------------------------------------
#endif	// !_dkbasic_h
//--------------------------------------------------------------------

